<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
</head>
<style>
    html,
    body {
        background-color: #fff;
    }

    .item {
        padding: 1rem 3% 0.5rem 3%;
        width: 94%;
        color: #000;
        border-bottom: 1px solid #ccc;
    }

    .title {
        font-size: 0.8rem;
        margin-bottom: 0.5rem;
    }

    .submit {
        margin: 0 3%;
        width: 94%;
        background-color: #388be2;
        color: #fff;
        font-size: 0.9rem;
        text-align: center;
        line-height: 2rem;
        height: 2rem;
        margin-top: 1rem;
        border-radius: 0.5rem;
    }

    input {
        width: 80%;
        height: 1.5rem;
        line-height: 1.5rem;
        font-size: 1rem;
    }
</style>

<body>
    <div id="app" v-cloak>
        <div class="item" v-if="index == 1">
            <p class="title">图文问诊价格</p>
            <div>
                <span>￥</span>
                <input type="text" v-model="price">
            </div>
        </div>
        <div class="item" v-if="index == 2">
            <p class="title">语音问诊价格</p>
            <div>
                <span>￥</span>
                <input type="text" v-model="price">
            </div>
        </div>
        <div class="item" v-if="index == 3">
            <p class="title">视频问诊价格</p>
            <div>
                <span>￥</span>
                <input type="text" v-model="price">
            </div>
        </div>

        <div class="submit" onclick="submit()">确认修改</div>
    </div>
</body>

</html>
<script src="../script/set_root.js"></script>

<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/zepto.min.js"></script>
<script type="text/javascript" src="../script/hb.js"></script>
<script type="text/javascript" src="../script/vue.js"></script>
<script type="text/javascript">
    apiready = function () {
        hb_ready();
        app.price = api.pageParam.id
        app.index = api.pageParam.index
    }
    //使用vue对数据进行绑定
    var app = new Vue({
        el: '#app',
        data: {
            price: 0,
            index: 1,
        },
        methods: {

        },

    })

    function submit() {
        if (app.index == 1) {
            post_ajax("doctor/services/save", {
                doctorId: $api.getStorage("emp").userId,
                name: "image",
                title: "图文",
                group: "consultation",
                values: {
                    price: String(app.price),
                    enable: 1
                }

            }, function (res, err) {
                // alert(JSON.stringify(res))
                if (res.code == 2000) {
                    toast("修改成功")
                    sendting("editService")
                    setTimeout(function () {
                        api.closeWin()
                    }, 200);
                } else {
                    alert(JSON.stringify(res.msg))
                }
            })
        } else if (app.index == 2) {
            post_ajax("doctor/services/save", {
                doctorId: $api.getStorage("emp").userId,
                name: "audio",
                title: "语音",
                group: "consultation",
                values: {
                    price: String(app.price),
                    enable: 1
                }

            }, function (res, err) {
                // alert(JSON.stringify(res))
                if (res.code == 2000) {
                    toast("修改成功")
                    sendting("editService")
                    setTimeout(function () {
                        api.closeWin()
                    }, 200);
                } else {
                    alert(JSON.stringify(res.msg))
                }
            })
        } else if (app.index == 3) {
            post_ajax("doctor/services/save", {
                doctorId: $api.getStorage("emp").userId,
                name: "video",
                title: "视频",
                group: "consultation",
                values: {
                    price: String(app.price),
                    enable: 1
                }

            }, function (res, err) {
                // alert(JSON.stringify(res))
                if (res.code == 2000) {
                    toast("修改成功")
                    sendting("editService")
                    setTimeout(function () {
                        api.closeWin()
                    }, 200);
                } else {
                    alert(JSON.stringify(res.msg))
                }
            })
        }

    }
</script>